package Text_2_0;

import java.util.Arrays;
import java.util.Comparator;

public class TextCode {
    public static void main(String[] args) {
        GirlFriend fg1 = new GirlFriend("king",22,170);
        GirlFriend fg2 = new GirlFriend("tom",12,160);
        GirlFriend fg3 = new GirlFriend("kit",25,180);
        GirlFriend arr[] = {fg1,fg2,fg3};
        Arrays.sort(arr, new Comparator<GirlFriend>() {
            @Override
            public int compare(GirlFriend o1, GirlFriend o2) {
                double temp = o1.getAge()-o2.getAge();
                temp = temp==0 ? o1.getHigh()-o2.getHigh():temp;
                temp = temp==0 ? o1.getName().compareTo(o2.getName()):temp;
                if(temp>0){
                    return 0;
                }else if(temp<0){
                    return -1;
                }else {
                    return 0;
                }
            }
        });
        System.out.println(Arrays.toString(arr));
    }
}
